#!/usr/bin/perl
#lvinfo.cgi
require './lvm-lib.pl';
&ReadParse();
my ($err_msg, $lvname, @pvinfo, @vginfo, @lvinfo, $l, $lv, $lock);

$err_msg="";
@pvinfo = get_pv_info();
@vginfo = get_vg_info();
@lvinfo = get_lv_info();
$lvname = $in{'lv'};
if (!$lvname){
	$err_msg="No VG select.";
	goto ERROR_OUT;
}

my $found = 0;
foreach $l (@lvinfo) {
	if ($l->{'lv'} eq $lvname) {
		$lv = $l;
		$found = 1;
		last;
	}
}

if (!$found) {
	$err_msg = $lvname."VG NOT FOUND.";
	goto ERROR_OUT;
}
&header($text{'title_vginfo'}, "", "", 0, 1);
#goto ERROR_OUT;
#my @vg_pvs = get_pvs_of_vg($vg, @pvinfo);
#my @vg_lvs = get_lvs_of_vg($vg, @lvinfo);
print "<table class=group border=1 cellpadding=4 cellspacing=0 width=100%>\n";
print "<tr class=title1><td class=group><b>VG Info</b></td></tr>\n";
print "<tr><td class=group><table class=mode1 cellpadding=3 cellspacing=0 width=100%>\n";
print "<tr><td width=250><b>Name</b></td><td>$lv->{'lvname'}</td></tr>\n";
print "<tr><td width=250><b>Volume Goup</b></td><td>$lv->{'vg'}</td></tr>\n";
print "<tr><td width=250><b>Status</b></td><td>";
print $lv->{'status_a'};
print "</td></tr>\n";
print "<tr><td width=250><b>Size(MB)</b></td><td>$lv->{'size'}</td></tr>\n";
print "<tr><td width=250><b>Free Size(MB)</b></td><td>$lv->{'free'}</td></tr>\n";
#my $perc = (1 - $vg->{'free'} / $vg->{'size'}) * 100;
#print "<tr><td width=250></td><td><table border=0 width=500><tr><td width=* bgcolor='#C0C0C0'><img src=jaune.gif align=left height=20 width=$perc%></td></tr></table></td></tr>";
print "</table></td></tr>\n";
print "</table>\n";


&footer("/lvm/", $text{'index'});
return;
ERROR_OUT:
&error_setup($text{'crt_err_title'});
&error($err_msg);
